package com.xiaohei.rabbitmq.eight;

import com.rabbitmq.client.Channel;
import com.xiaohei.rabbitmq.utils.RabbitmqUtils;

import java.nio.charset.StandardCharsets;

/**
 * 死信队列 生产者
 * @author: 王希辰
 */
public class Producer {
    //普通交换机的名称
    public static final String NORMAL_EXCHANGE ="normal_exchange";

    public static void main(String[] args) throws Exception {
        Channel channel= RabbitmqUtils.getChannel();
        //死信消息 设置ttl时间 设置单位ms
//        AMQP.BasicProperties properties=new AMQP.BasicProperties()
//                .builder().expiration("10000").build();
        for (int i = 1; i < 11; i++) {
            String s = "info" + i;
            channel.basicPublish(NORMAL_EXCHANGE,"zhangsan",
                    null,s.getBytes(StandardCharsets.UTF_8));
        }
    }
}
